package com.jimmy.medical.enums;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @Desc: 列举所有的角色类型，key对应role表的ID

 * @author jimmy

 * @date 2018-04-27
 */
public enum RoleTypeEnum {
	DOCTOR(2, "咨询医生"),
	WAITING_ROOM(3, "候诊室"),
	DOCTOR_ASSISTANT(4, "咨询部助理"),
	WAITING_ROOM_MANAGER(7, "候诊室经理"),
	CUSTOM_MANAGER(9, "客户经理");
	
	private int key;	//代码
	private String text;	//名称
	
	RoleTypeEnum(int key, String text) {
		this.key = key;
		this.text = text;
	}

	/**
	 * 根据key获取名称
	 */
	public static String getTextByKey(int key) {
		for (RoleTypeEnum obj : RoleTypeEnum.values()) {
			if (obj.key == key) {
				return obj.text;
			}
		}
		return null;
	}
	
	/**
	 * 将枚举类型转换为Map
	 * @return
	 */
	public static Map<Integer, String> getMapValue() {
		Map<Integer, String> map = new LinkedHashMap<Integer, String>();
		for (RoleTypeEnum obj : RoleTypeEnum.values()) {
			map.put(obj.key, obj.text);
		}
		return map;
	}
	
	public int getKey() {
		return key;
	}

	public String getText() {
		return text;
	}
}
